package com.ygk.bluepath.member.Presenter;

import com.ygk.bluepath.R;
import com.ygk.bluepath.core.BFragment;
import com.ygk.bluepath.core.BPresenterFragment;
import com.ygk.bluepath.member.View.RegisterActivity;

import org.json.JSONObject;

import java.util.HashMap;

import utils.ImageUtil;
import utils.Inf;
import utils.PostFormForPresenterFragmentUtil;

/**
 * Created by Handreace on 16-7-13.
 */
public class RegisterPresenterFragmentThree extends BPresenterFragment {

    public RegisterPresenterFragmentThree(BFragment fragment) {
        super(fragment);
    }

    public void choosePic() {
        ImageUtil.showChooseDialog(getActivity());
    }

    public void completeSubmit(String carNum, boolean isChooseFront, boolean isChooseBack, boolean isChoosePeople) {
    }

    public void ignoreSubmit(String carNum) {

        if (carNum.isEmpty()) {
            tt(getActivity().getResources().getString(R.string.carNumIsEmpty));
            return;
        }
        ((RegisterActivity)getActivity()).setCarNum(carNum);

        getActivity().bMap.clear();
/*        getActivity().bMap.put("mobile",((RegisterActivity)getActivity()).getMobileNum());
        getActivity().bMap.put("name",((RegisterActivity)getActivity()).getRealName());
        getActivity().bMap.put("password",((RegisterActivity)getActivity()).getPassword());
        getActivity().bMap.put("id_card_no",((RegisterActivity)getActivity()).getCarNum());*/
        getActivity().bMap.put("mobile","13257570363");
        getActivity().bMap.put("name","handreace");
        getActivity().bMap.put("password","123456");
        getActivity().bMap.put("id_card_no","粤A3456");

        getActivity().bMap.put("device_type","1");
        getActivity().bMap.put("device_token",getActivity().sp.getDeviceToken());

         HashMap<String, Object> picsMaps=new HashMap<String, Object>();
        picsMaps.put("card_front_pic",((RegisterActivity)getActivity()).getIdentificationFrontUrl());
        picsMaps.put("card_back_pic",((RegisterActivity)getActivity()).getIdentificationBackUrl());
        picsMaps.put("member_pic",((RegisterActivity)getActivity()).getIdentificationFaceUrl());
        getActivity().bMap.put("picsMaps",picsMaps);
        new PostFormForPresenterFragmentUtil(this, Inf.URLHEAD+"member/register",getActivity().bMap,true,true,"register","").execute();

    }


    @Override
    public void dealJsonObject(JSONObject result, String oid, Object extraStr) {
        super.dealJsonObject(result, oid, extraStr);
        if (result!=null){
            String msg=result.optString("msg");
            tt(msg);
            int code=result.optInt("code");
            if (code==0){

            }

        }

    }
}
